package wan.com.templateproject.mapper.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import wan.com.templateproject.entity.People;
import wan.com.templateproject.mapper.PeopleMapper;

import java.util.List;

/**
 * @author wan
 * @version 1.0.0
 * @Description TODO
 * @createTime 2021年08月17日 14:19:18
 */
@Service
public class PeopleMapperImpl extends ServiceImpl<PeopleMapper, People> {

    QueryWrapper<People> qw = new QueryWrapper<>();

    /**
     * 增
     * @param people
     * @return
     */
    public boolean insertPeople(People people) {
        return this.save(people);
    }

    /**
     * 删
     * @param people
     * @return
     */
    public boolean deletePeople(People people) {
        //得根据条件删，这里根据名字删
        qw.lambda().eq(People::getName,people.getName());
        return this.remove(qw);
    }

    /**
     * 改
     * @param people
     * @return
     */
    public boolean updatePeople(People people) {
        return this.update(people, qw);
    }

    /**
     * 查
     * @param people
     * @return
     */
    public List<People> getPeople(People people) {
        qw.lambda().eq(People::getName, people.getName());
        return this.list(qw);
    }
}
